﻿function Get-TSMPolicyDomain {    
    <#
        .SYNOPSIS
            Get TSM policy domains
                    
        .DESCRIPTION
            The Get-TSMPolicyDomain returns policy domains

        .PARAMETER Domain
            Domain to search

        .EXAMPLE
            Get-TSMPolicyDomain

        .NOTES
            Contributors:  David Seibel
            Last Revision Date: 09/01/2015

    #>
    [CmdletBinding()]
    Param(
        [Parameter(Position = 0)]
        $Domain
    )

    $whereProps = @()
    $whereProps += [PSCustomObject]@{ "Column" = "DOMAIN_NAME"; "Operator" = "LIKE"; "Value" = $Domain }

    $query = Format-TSMQuery -Table "DOMAINS" -Where $whereProps -OrderBy "DOMAIN_NAME"
    $result = Invoke-TSMCommand -Command $query

    $defaultDisplaySet = 'DOMAIN_NAME','DESCRIPTION','NUM_NODES'
    $typeDefinitions = @{
                        "ACTIVATE_DATE" = [DateTime]
                        "CHG_TIME"      = [DateTime]
                        "NUM_NODES"     = [Int32]
                        "BACKRETENTION" = [Int32]
                        "ARCHRETENTION" = [Int32]
                        }

    return Format-TSMData -Data $result -TypeDefinitions $typeDefinitions -DefaultDisplaySet $defaultDisplaySet
}